package br.com.center.loja.ws.dto;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class OrderItemDTO implements Serializable {
	
	   private static final long serialVersionUID = 1L;
	   
	   private Long              code;
	   
	   private OrderDTO             order;
	   
	   private ProductDTO        product;
	   
	   private Integer           quantity;
	   
	   private Double            discount;
	   
	   private Double            price;
	   
	   private Double            finalPrice;
	   
	   {
	      quantity = 1;
	      discount = 0.0;
	   }
	   
	   public Long getCode() {
	      return code;
	   }
	   
	   public void setCode(Long code) {
	      this.code = code;
	   }
	   
	   public OrderDTO getOrder() {
	      return order;
	   }
	   
	   public void setOrder(OrderDTO order) {
	      this.order = order;
	   }
	   
	   public ProductDTO getProduct() {
	      return product;
	   }
	   
	   public void setProduct(ProductDTO product) {
	      this.product = product;
	      
	      setPrice(product.getPrice());
	   }
	   
	   public Integer getQuantity() {
	      return quantity;
	   }
	   
	   public void setQuantity(Integer quantity) {
	      this.quantity = quantity;
	   }
	   
	   public Double getDiscount() {
	      return discount;
	   }
	   
	   public void setDiscount(Double discount) {
	      this.discount = discount;
	   }
	   
	   public Double getPrice() {
	      return price;
	   }
	   
	   public void setPrice(Double price) {
	      this.price = price;
	   }
	   
	   public Double getFinalPrice() {
	      return getPrice() * getQuantity() * ( 1 + getDiscount() / 100 );
	   }
	   
	}


